Increasing performance by optimizing db calls & refactoring logic for Definition objects