Cleaned MainUI's code a bit.