Simplify some code and fix DetailFragment handling