cleaned up new mean-removal code