fix for #168

Fix for #168. Tested for both colorPerVertex=TRUE and colorPerVertex=FALSE.