Tidied up variables and error

Deleted erroneous variables and changed error to native error class.