Refactored gui.

Way too much changes in one commit.