UI functions, corrected some bugs