Changes from (https://github.com/DavidRagazzi/nupic/pull/4) inserted manually