Added some comments about the regex used. Minor code cleanup.