Code Cleanup and Documentation