Fix instance null exception
Refactor creating entity instance process.