fixed issues with non-standard scripts (hackish!)