Fixed a javascript error with the name of a variable.
Removed query logs and added LIMIT clauses to some queries for optimization.
Added migrations: Some index are created and function _getRiskTotal is rewritten.