Fixes issue #510 and #156, as well as issues addressed in PR #373.
Actually fixes #156!
Incorperates more changes from #373 in order to fix issue #296
Caught bug, fixed bug. Server becomes inactive before isOnline() check.
Fixed minor formatting issues and removed <139 lines of whitespace