Refactoring

@karllindmark please merge as soon as possible

Extracted fragment/dialog fragment casting logic into BaseFragment