updated for version 1.6.1
merged in changes from 1.3.1