Added Events support, and fixed possible JSON bug