Fix bug where app becomes unresponsive