Replace context instance per function with single reference counted instance