Fixed pattern bugs in new code

Accidentally added a few bugs in that latest patch. I've now tested this code as good as i can and it doesn't do anything silly. Zooming code is still bugged but as said previously i really need something that calls it to know how to fix it.