Make -n and -p faster