Simplify some callbacks in ui.js