Cleaned up main mostly. Added flags also.