[lib + engines] several bug fixes