Fixed some bugs relating to floodfill