Reworked side effects to factorize code.