Refactored GUI code.