Fix bug where rewrite rules could cause incorrect output
Fix bug where rewrite rules could cause incorrect output

Closes #8

beni55/binary,ezyang/binary,bergmark/binary,flowbox-public/binary,beni55/binary,fpco/binary,flowbox-public/binary,basvandijk/binary,x456/binary