Updated documentation, refactoring.