fixed errors, more debug statements