Add lock and visibility to the python api.
Seems however that these aren't saved properly. Also fix up some other details.