Fix dispose issues identified by Gendarme (part 2)

This patch includes the cases that required changes in production
code.

Change-Id: Ia7dbabdb6fe605be7fc78c0cb7f986d3b8749f39