added code from libbasnet
Merge branch 'dev' of https://github.com/Lensman/libbasnet into dev