You need to initialise `t_valueref` and `t_valueref2` to `nil` if you use `if (t_valueref != nil)` later on.