Remove extra files and add permission checks