Applying patch from https://issues.numenta.org/browse/NPC-356