Refactoring

Sorry, this is the less useful commit description I ever written. What
that means is that it works in all major browsers and I fixed at tons
of bugs.