event handling and code cleanup
added credit for jack plugin