Fix issues with async modules and new middleware API.