lots of forgotten code fixes