[nim, dj] Refactoring to give script a useable API