Graceful exit 32bit fixes, refactor, cleanup and rebase.