Clean up the logging code + upgrade mongoose to stable version