[fix] Attempt to fix Ubuntu problems reported by valgrind