moved background.html to /html/
small spot fixes and refactoring
removed implicit global declaractions, made local
changed some names to follow style guidelines
changed inner variables to not conflict with outer