more cleanup and breaking into smaller files