instanceOf() and as() bugfixes