Added more comments and new profile_endtime_sql