Fixed some bugs
Some fixes & improvements