update to use sql.
put models.
delete unecessary classes for www mode.