improve signing and add checking of signatures