Variety of changes to fix trees and support chained mappings

See commit messages for details