Bug fix: use typeof for object check.