fix build errors/warnings
refactor finishConnect a little