Code suggestions

Various suggestions - happy to discuss. Review carefully, something may have broken somewhere.