Added comments and cleanup.