Some fixes

Infinite loops
'j' into a string causing invalid chars