Bug-fixing pass (all warning are belong to us)