Various cleanups to core