Fix connection bug, add more documentation