Buffer overflow bugfix