Inclusion of boundary calculation

plus some bug fixing.