Backport #1552. Also Refactor ManagedServiceInterceptor to make it extendable