[#3533] Lots of nice changes thanks to @xabbuh