boundary refinement and minor fixes