Slight cleanup to keep all VM operations in methods.
Dirty fix to bring the post-disconnect logic out of the afterDisconnect method, to avoid two calls on separate threads.