Add a kernel file reading function, fix some bugs.

Some redesigning of the utility library is needed, but let's make a few
sample programs first to see what is actually needed in practice.