numerous script and source bug fixes