lib3 + some earlier edits

I don't know how to not commit everything, but only the latest commit :-(