introduce models.py and dao.py, move some code around.