Updated documentation, refactoring