Account for various boundary conditions.