cleaning up & making it work with upstream; WiP