Update main for single-instance app
First pass of single-instance