utils: fix memory leak + some small fixes

refs #2137

Change-Id: Iacb0825ef124ca033105010655947a1282844123