Clean up and permission checking