Added first round of peephole optimization, although it's a little hamfisted