Fast and Correct Gradient-Based Optimisation for Probabilistic Programming via Smoothing