AutoTests and several fixes