fixed bugs in generator
fixed a pretty serious bug when calculating the type of derived and opaque units