Fixed permissions and take allowed types into account