Updated network code, but still a bit buggy