Fixed bugs and added stat hook