Adding some comments, reorganizing functions and documentation.