Support event-based/on-demand patching; Add default values for parameters; Fix some bugs