Improve type guessing code and fix issue with guessed strings