Shouldn't it be len(g.free_parameters) instead?