followed HLint's suggestions. GUI now broken but everything else is okay