Cleaned up undefined variable errors