CRA-534: Fixed some small bugs and merged with nrlib.