Adding debug messages and fixing typo on to_string