Fix SLD output (still need to be reviewed and tested)