We present a novel dynamic programming framework that allows one to compute tight upper bounds for the p-values of gapped local alignments in pseudo–polynomial time. Our algorithms are fast and simple and unlike most earlier solutions, require no curve fitting by sampling. Moreover, our new methods do not suffer from the so–called edge effects, a by–product of the common practice used to compute p-values. These new methods also provide a way to get into very small p-values, that are needed when comparing sequences against large databases. Based on our experiments, accurate estimates of small p-values are difficult to get by curve fitting.