Bug fixes and changes to casting. Added Object:instanceof.
Merge remote-tracking branch 'upstream/master' into smaller-archive