Fixed reverse query bug

This was previously setting scan_index_forward to the same value as the passed-in reverse parameter; it should be the opposite.