kmod/core: long overdue cleanup

Some *much* needed cleanup for the core module.  Don't be intimidated by the number of commits -- they're mostly trivial, except for the last commit.