Optimise some program logic.