fix for older version opnmp
check density updating
change comments
shorten codes