Improvements

Hi Jono,

I refactored some stuff, maybe you wanna take a look :) I tested it on my computer within chrome and
firefox. If you decide to merge please also test the code before.

xat