A series of bugfixes for the recent branch_periodic_bc merge

This pull request addresses a bunch of regressions introduced with the last
pull request for periodic boundary conditions.

It fixes the currently failing tests (hopefully :-]), reorganizes a bunch of
code, adds some additional Assert and comes with some documentation fixes.