Rearrange deref to fix input problems.