privacy made more robust and shifted code around to have better locality and scoping