ugly fix for stucts and reference types inside objects
TODO: REFACTOR!