Fixed some bugs, performance improved