Introduce plugin system, move some behavior into plugins