Refactoring and doc update