Apply profiles from middleware in main

When loading the project, ensure that profiles contributed by middleware
are correctly applied.