Update to new API; bug fixes and fix for failing test