fixed JPG on 2d and added call to onstatechange for grid setup