Modify secure_device_mem function and source clean-up.