Added comments and cleanup