Greatly simplified script
More general cleanup