added silvio's code to clean up extended gui