Slight cleanup of staged function code