Solved some bugs, implemented framework for statistics.