Small logic changes