Fixed a few bugs and saved the key size into settings