applying Renan's #635 changes.