Refactored to merge regexes and cleaned up code a tiny bit.