Fix if constant handling

Slightly more optimal if compilation, including a fix for always true/false constants (which was failing due to the strict comparison), and better handling of empty else.

Doesn't (quite) merge cleanly with #293, so I'll rebase one if the other is accepted.