Added debugging, db queries, input regexing, and testing