valgrind-friendly v4

Signed-off-by: Denis Zalevskiy <denis.zalevskiy@jolla.com>