Validation fixes

Fix str_replace overwrite in error message.