minor layout and logic improvements