Lots of minor changes to layout and logic