Patches from jpartyka