Clean and update build output more intelligently

Fixes #183.
please don't wrap, also i think these can fail - they need to be protected with try/catch