Code tweaks and notes from Daniel.