Bug-fix:

 - Handle const tmp issues during gradient calculation