Patches from master

- Better 64-bit support
- Bug fixes