Enabled exit function
Added exit
Fixed build warnings, cleaned up new code