port init mode to python3, this new code has not been fully checked