Bug fixes for api