updates to latest API and other improvements in codes