added implementation for new instance creation and fixed some minor bugs