Refactored Gui Logic

Reviewed by: Simon