Migrating some old python code here for translation