Working structure auto-generation. Buttload of refactoring needed...