Added functionality and fixed a few erros in localization.py