Added needed comments, reorganized some code...