Simplify and document util functions.

I'm also working on factoring out the package-tree loading code (util.loadSubmodule) into its own package. I'll make a new pr for that.