Added Peter Ballen's changes.