Start shrinking zmap.c

Move utility functions to lib/util.c