Latest version. Moved function from basereality, tidied other stuff up.