Extract text manipulation functions from SessionController