Remove accidentally duplicated code + minor cleanups

Perhaps during one of the recent merges.