Made refactoring of some classes without changes in functionality, and added documentation.