A £1 million programme to reduce train delays and cancellations caused by fallen trees on the Heart of Wales line is nearing completion.