Bugfix and additional data checks. New algorithm is backwards compatible with already stored data files and corrects errors introduced by previous version of the algorithm