More bug fixes and 64-bit support

I still can't believe I forgot to actually throw the errors...