Modularize implementation of LeakDetector into a typed template