Code cleanup in Core