moved more logic from core to plugins