added wrapper classes to handle results of db queries and pattern matching