Fix wrong boundary calculation (bug #17)

This fix doesn't currently work concurrently. This will be fixed in another commit.