Adding proper cleanup

As per bug 30895