Add missing return in detach().

Move messages to more appropriate place.