Finish connection testing, fix a bunch of bugs