removing debug echos and adding some minor fixes.