Remove UI dependency of commands. Apart from the cleanup, this eliminates potential bugs during undo.