Added code from opencb-commons