fix bug with mouse being in wrong focus
clean up code