updated api
Merging Alex's latest changes.