again fixed a few bugs within patching routine