refactored varnish, other misc fixes