locate: bugfix + better handling of local modules

Locate on nested local modules is still unsatisfactory though.