[BREAKING CHANGE] Fix camel-casing of countNonInternalElements

Also add minor optimisations.

Breaking change: function renamed.

Change-Id: Id3d6da8730eb81e4cab99c91521a7b6d1b46684a
Merge "[BREAKING CHANGE] Fix camel-casing of countNonInternalElements"