Fix a couple bugs in remote stub gen and structure detection