Add TreeSelection signal and other fixes

This adds support for listening for tree selection changes. I also added some miscellaneous fixes for problems I found as I went along, such as making some parameters mutable or optional.