Unify struct initializer codegen, fix it for unions 

This pull request contains quite a lot of changes, but I tried to separate them out into logical chunks.

Fixes: #351.

DO NOT MERGE YET