Changes for new callback format and cleanup code.