Squashed everything from numenta/nupic#364 into nupic.core

cc: @breznak re:  numenta/nupic.core#8 and numenta/nupic#364