Issue #705 Replace pseudo-private functions with file-scoped functions

Please check this first commit. If it is ok I will do the same thing with other functions.