Many important bug fixes