Finished restructure - needs testing