Reworked implementation.