Fix path resolution and file cleanup