"Borrowed" code from SB's post-processing routine.