Weird behaviour when using dsm
You may be experiencing a Krumo side effect:

https://drupal.org/node/1855468

The problem is that PHP handles references to array elements in a risky way, see this article: PHP: References To Array Elements Are Risky

I haven't read the post deeply, and can't assure you have this problem, but you may try the workaround to see if it works: use Krumo NG.

Another way is to use dd to dump your traces to a file, see functions documentation: https://api.drupal.org/api/devel/devel.module/function/dd/7