Fixed out of bounds errors in server thread