region labelling and code cleanup