fixed some bugs. refactored UI