Fixing undef variable warning and typo