Fixed bugs introduced by the adition of haystack