Added object selection controls.

I'm not perfectly happy with some of this code, but it works.