A little bit of trimming on the regex. Fixed some bugs.