fix dns upon startup
typo
Factorize all memoize functions

@jpcw @regilero, this was a tough one ...