Some changes after a code review by alan