Code Cleanup and formatting