Refactor util/mknum.pl for clearer separation of functionality