some api and db fixes