fixed some bugs and more improvements