added some comments and a little cleanup, still more to do