Added element info as JSON, and cleaned up Javascript.