Attempt at improving replace module a bit.

Nothing major, just some minor changes that might make it easier to overview.