refactoring models and some bugs fixed.