bit of cleanup and added some comments