Added market type entity. Refactored code