Added codes, refactored models