Fix routes and reduce DB calls in stats view