Moved mongo connection logic to its own file
Fixed bug when attempting reconnect