Implement class and instance patching

TODO:

- [x] implement class patching
- [x] implement instance patching