Minor cleanup

Fixed a regex, and tidied up some code a bit.