Minor reshuffle of internal logic with intent to test it properly.