Added error handling to script generator

also refactored install Location code