fixed keyring option functionality; lots of code cleanup