clean up and fix permissions