Fixed attachment and detachment of fragments to prevent loss of context
when switching between tabs