update cudalib to handle return values correctly.