Better optimization pipeline

This is a better pipeline, both faster-running and produces faster code.

For some reason the `mergefunc` pass screws over resolve. I have no idea why though.