Fix bug when updating applying patches