Modified code to work with the actual core code and API.