Made string parsing slightly more robust