First commit, mostly comments about how to convert old version to this new format and fixing the algorithm.