some cleaning up and commenting