Upstream/var imp

Bring varImp back into master with proper tests.