BIG modification to server logic (fix conversion)

remove alot of bad code and unnecessary variables
removed many unnecessary loops
fixed conversion check