added more comments, cleaned up