ported more generalized handler stuff from csc fork