Minor fixes, cleaned up the code a bit. Works better in Firefox.