Add texts to improve debugging

and remove a few small bugs