:memo: added extensive comments, :gem: removed unnecessary code, and some 'prettification'