extract some code from the core