Cleanup accidentally removed some necessary code (because it wasn't used yet), added back the regex checks to verify that lines are valid.