Replacing sections of API code, issue #231.