Corrected all internal logic.