Fixed database logic, modified each problem type, refactored more code