Simplifies "end" calculation.