Code refactored, with Model-View-Controller pattern applied. Program appears to function identically to before, no new known bugs.