Switched to using functions library => removed dependency on XEH.
Replaced spawns with calls to remove the need for checking whether we're switching - logic is now blocking so no need for that.
Cleaned up config and fixed inheritance issue.