minor cleanup of main functions