Bug fix in API.session