Fixing segfault. Off-by-one when setting number of dimensions in StreamingSparseFeatures.

* Commit 4fae70c is a fix for #1441 plus some sanity checks
* Commits 3ac91b7 and bc4bfa0 are refactorings to reduce code duplication.
* Commit 0288090 fixes wrong broken unit test and some debug output.
* Commit 21e82a8 contains simple improvements (disabling ref counting for temp vectors)