Fix app starting logic

Fix #862