Added changes by @knu