Bug fixes for Several Scripts