Refactored code to use Q deferred

Also, the statistic commands get their own class for better organizations