Updated docs, some refactoring fixes