Study shows smaller class sizes not always better for pupils