Fixes regular expression and cleans up JS a bit