improved efficiency and readability

only slightly, but seems worth it - even though it's kinda weird relying
on a variable declared in another if branch
ensured binary files are removed on deletion