reduced memory strain on count
Merge branch 'master' of https://github.com/PrashantSridhar/sp2014.11-731
count should be faster and use less memory