Locking fixes, some changes in data model