various tweaks to get to a first version that basically works