Bug fix in api_session