Fixed bugs that only discoverd thanks to vapnik