improvements by mrdemc from dienstkoning