Add plugin hooks and fixes few things