many many changes to support mongodb