Nearly finished local switching; fixed bug in openXLink function