Split config, merge handlers and restructure core