Cleanup, moved exception handling to main