Code cleanup and documentation

Add summaries and did code cleanup