Fix up dynamic programming and use greedy bounds