Graceful exit 32bit (Issue #336)

re-submitting bill's PR with my fixes on top.
I've rebased his work and mine.

Closing his PR, to continue working on this one.
Revert this line to the original code.