This is a combination of three patches (the first two for adding