Clean up code for symfony 2.6/3.x compatibility.