bug fixes for the Cosmos wrapper