Refactor config, weave and unweave