more compact serialization of bdd's taken from original repo