Fix linked list manipulation code (buggy on consecutive deletion)

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>