Minor cleanup, move code from utilities to core etc.