Major buffer overflow bugfix.