general cleanup and preparation