Proper exits and preg_match() fix