Fix Server errors

-Rand() issues
-Stop closing the connection too early