Fixed issue causing disconnect events to be missed, refactored web app connection stuff a bit