A few bug fixes and API changes