Some basic logic cleanup to get rid of a bunch of regular expression calls.