api and bug fixes