Updated and refactored patch system