Mainly code clean-up and some refactoring in the API classes.