Based on a patch by Sergiy <piratfm@gmail.com> SVN-Revision: 27809
Based on the patches from #9625 SVN-Revision: 27396