Changed some stuff like if1 to if0 (i.e. make it 0-based)