Fix bug in process_tube (it can write wrong statistics)