Fix callback issue and make it parameterizable.