Enum fixes.
Massive refactor to support ref structs.

This was required because Lua semantics are always by reference.
With the original struct-by-value implementation, it was impossible to do something like "myStruct.subStruct.i = 10", because, subStruct would be copy.