Fix permissions
Clean up code