Some values are written in different variables, you have to write into both to get it to work. (Or pointers on the variables, but well, only works if changing both)
And to that custom pattern stuff...well...i just copied it from my trainer, not so much effort in it...