Small subset of hopefully uncontroversial changes from PR #1108.
Merge PR #1392 by @emanuele3d - some architectural fine-tuning