Rewritten to comply with PEP8. Further tuning of GUI/functionality.