fixed small bugs and "generate statistics" not working bug