Refactor to remove circular dependancies