refactor of fragment code and some cleanup and fixes
Merge pull request #4 from Phil-Friderici/fragments

refactor of fragment code and some cleanup and fixes