fixed issues with reading keyfile from memory and disk