Refactoring. Adding some doc.