Add key setup script
Fix unbound variable bug