Added a readOnly option.
Fixed a global scope leak.