MORE WIP Tidying structure to work with new application layer and query layer