Important bug fixes

As above