more touchups and code cleanup