Refactor JS a little bit, storing settings into a var