Fixed buffer issue, modified loop data struct