Removed notices, exception handling, and fixed preg_match()