Major overhaul of the GUI code with full error checking and much easier code to maintain.