Refactored and fixed angular script generation