Looks like I missed to add a break to the while loop due to rare occurences of lost connections in testing. Will change that.