add some debug and string cleanup