Move Pattern code around

I think this is a bunch clearer.