Added documentation for recording, cleaned up code