Fix IntDirection out of range bug