fix obvious memory problem
fix minor bugs
commeted out debugging messages