Added lifecycle events. Fixed #18