Further work on embed2, bringing code from front end javascript to server side python.