Fixed single-application instance issue

can you please fix this, might break a lot of things if this goes into master.