Fixed some bugs caused by RavenDB linq management.