Improve stat and clean functions