cleaned some code, made a sligtly improved version of greedyfirst.