References and error pointers

Fixed the error pointers to initialize to 0. Made sure that the structs
receive a reference and not a copy to reduce the number of copies being
made.