Fix array de-ref bugs and add some #defines.