Fixes logic errors.