Fix issues with selection preservation and replacing smileys