fixes #14

check for out of variables in wrong place
fixed variance calculation
fix reset issue