Large rewrite of the kb[] accessor

Refer to docstring for the new behaviour.