Fixed permission, tidied code