Fixed some bugs
Some improvements