Should move all this into a common method.  It's copied all over the place.