minor code tweaks and draft of stdranef function