Fixed a number of bugs. Now the IR that comes out does not look completely wrong.