collapse duplicate variants
add malloc debugging
remove optimization for now