SQL query and inconsistencies fixed, TODOs.txt updated