Merged patch from aitte