Remove unnecessary JS methods and refactor regexps