Restructered core code