Code refactoring: extended comments and removed obsolete code.