some performance improvements, still no priority queue :)