sql, timer and history fix