Fixed bugs in GUI; better error handling needed