Fixed a nasty buffer overflow bug