Major refactor - continued 2