Added many doc additions as well as some refactoring.