Fix #547 and #557
Fix #547 and #557

DoNotUseThisCodeJUSTFORKS/cryptocat,arno01/cryptocat,DGO143/cryptocat,wakermahmud/cryptocat,Cryptodog/cryptocat,Cryptodog/cryptocat,DGO143/cryptocat,PeterDaveHello/cryptocat,wakermahmud/cryptocat,Raynes/cryptocat,DGO143/cryptocat,DoNotUseThisCodeJUSTFORKS/cryptocat,DoNotUseThisCodeJUSTFORKS/cryptocat,Raynes/cryptocat,arno01/cryptocat,PeterDaveHello/cryptocat,Raynes/cryptocat