Rewrote UI handling section.

Was I suffering from temporary insanity before? Ew.
Response to UI still needs tweaking, but it's good enough for now.