Cleanup, comments and formatting