some changes on database structure and some small fixes for further work.