added a bunch of utility, fixed some bugs with UI