Applying daeiron's patch

change id is I7709d33ca06f1126f1fce8d6fce07332fb82329b