Repaired getLength(), countOfOnes() functions