fix a few ptr bugs and add a recent-ip cache