Implement class and instance patching

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