Adapted server code for Python3