Documentation update and code refactoring