Remove old stat controller, and replace it by new Stat functions, refactor the involved JS code for #30