Fixes bug when replacing empty strings with nils