Fixed bugs in GUI and reorganised