Some speed improvements

Added indices and a slight tweak to @count