Need to specify link order properly, and -lm, on debian
Fix silly array bound mistake