simplified some regexes
and minor changes