added path finding. general tidy up