fixed some bugs, refacotring, view changes