Documentation, refactoring and code format