Code changed to work with the new API.