Typeof and instanceof problems -- done