Major refactor - too much to list!