some design changnges and db fixes