Add pattern processing capabilities, lots of other minor changes