Small changes to docs and some refactoring.