Modifications to check_pattern to better fit project needs.