added readJSONObject method, optimized event handling code to reduce CPU
cycles