merging magstock changes into Dom's repo

they're common i.e. not-specific to magstock

some of these are already obsoleted by code Vicki did.