Fix undefined value errors