removed not used code
added better support for singleinstance
moved app logic away from main.py