Fixed python3 compatibility. Still segfaults in network for some reason