Overhaul part 2

 - Second part of huge overhaul to modularise functions of the API and
remove controller dependencies