Refactoring and addition of documentation (design notes)