Resolved some unwanted cases of bufer overflow