Slightly improved version of mystrtok_r