cleanup and misc improvements