Refactoring some and updating docs.