Improve code generator functionality. Although... it is not at all
pretty. Maybe we really should use some fat templating library
instead...