Fix reloading classes with middleware