Add Document constructor for explicit IDs
Fix ClassCastException