Refactoring

Eliminate duplicate code and clean up the main files of sailfish and
harmattan.
Merge pull request #87 from michael-k/cleanup

Refactoring