sanitizing gui behaviour and some code cleanup