Several fixes, thanks to @sameoldmadness