Verify that target buffer exists before switching.
Merge pull request #47 from thomasf/master

Verify that target buffer exists before switching.