Implemented text buffer overflow protection

Temporary workaround: If the text exceeds 511 characters, a warning will
be given, and the excess will be cut off.