even more minor cleanup
more 64-bit fixes for incorrect downcasting