Capturing dynamic correlation with variational explicitly correlated wavefunctions