Rename index variable to a more sane {p -> i}
Fix the ptr callback signature, shouldn't be in ST