Fixed stat calc to be more efficient, not query DB every new run. Fixed input validation and limited to realistic values.