Maxmind memory leaks

This includes two commits from master