Fix ArgumentError and ReferenceError