pattern optimizations v2

https://github.com/inliniac/suricata/pull/1033 and https://github.com/inliniac/suricata/pull/1047