Fixed overflow bugs by CurlyMoo