Update modreg.c

Making important changing and cleaning up