Fixed event callback issues, added explicit cleanup mechanism