Patch contributed by Daniil Ivanov (ext-danil.ivanoc@nokia.com)