Add pattern->node compile caching

Many patterns will be used again and again, this prevents us from
compiling common patterns multiple times