refactoring and interrupt support

In case anybody is interested, I added a couple of things:

- minor refactoring: common patterns are now private methods
- added support for interrupts
- added support for interrupt configuration