bugfixes on plaintext, needs testing before production use