removed some debugging, added some comments, more work on optimizaiton