Added @Peppie23's patch for FocusFragment.

Also changed var declarations to explicit types for improved code readability.