added automatic inheritance reference
improved code organization