Fix handling of optional callbacks