Fixing window frame manipulation in Hammerspoon

I use Hammerspoon to automate all sorts of things on my Mac. I've been running into some annoying issues where trying to use :setFrame(...) and the like on hs.window objects would behave erratically.