PAHMA-741: fixes handling of crates. And lots of other minor changes.