Miscellaneous code bits of mine, mostly R