Added code from C side.