Updated data model and several bugs fixed