Added keychain wrapper and few optimizations