Several fixes for script output