Fix buffer overflow, fix #7