Partial rework of gui logic.