Added code and classes for self-localization, not yet tested.