fixed region bug, few small modifications