Sanity bug fixes