Refactored Gui_Click function

I hope to have made everything a bit clearer. It's a long method by nature, so we won't be able to make this as pretty as we might like.