Added "error" function and cleaned up code some more.