More locking, generalized element parameters

And lots of misc..