Clean up temp folder, correct error raising