This makes things a little more generic and robust.
Tests and docs will be added tomorrow so we can merge the new resources…