an extremely ugly but effective "destroy" implementation