incorporated changes from anish.  memory usage reductions and config fixes.