removed some dead code, added comments to main