Ensure variables are set before you use them, and remove redundant code
Fix installer error