Fixed some bugs. Tested on big project