Plugin updated for options and custom events