[core] Code partly refactored.