Added some comments, restructured cpp-file.