Cleanup and encapsulate body into main()