Added event functionality and minor fixes