Endpoint.scala cleanup

This does not solve 3286, alternate solution under way.
This PR cleans up a bit of var-twiddling.