Refactoring and modularization

Refactored code into more manageable pieces - separated window control from pebble application etc.