A start on fixing #994

@igorko please test, if the warnings will be less.