Cleanup variable access and pull in lots of working functions from teash19