removed assertion for input parity, made decode private
changed sets to dicts (not lists of tuples), added sanity checks for results.