Refactoring

Eliminate duplicate code and clean up the main files of sailfish and
harmattan.