improve stats and cleanup