PyMODINIT_FUNC initaerospike()
{
	// Makes things "thread-safe"
	PyEval_InitThreads();

	// aerospike Module
	PyObject * aerospike = Py_InitModule3("aerospike", Aerospike_Methods, 
		"Aerospike Python Client");
	
	PyTypeObject * client = AerospikeClient_Ready();
	Py_INCREF(client);
	PyModule_AddObject(aerospike, "Client", (PyObject *) client);

	PyTypeObject * key = AerospikeKey_Ready();
	Py_INCREF(key);
	PyModule_AddObject(aerospike, "Key", (PyObject *) key);

	PyTypeObject * query = AerospikeQuery_Ready();
	Py_INCREF(query);
	PyModule_AddObject(aerospike, "Query", (PyObject *) query);

	PyTypeObject * scan = AerospikeScan_Ready();
	Py_INCREF(scan);
	PyModule_AddObject(aerospike, "Scan", (PyObject *) scan);

	PyObject * predicates = AerospikePredicates_New();
	PyModule_AddObject(aerospike, "predicates", predicates);
}
PyMODINIT_FUNC initaerospike(void)
{

	static char version[6] = "1.0.58";
	// Makes things "thread-safe"
	PyEval_InitThreads();
	int i = 0;

	// aerospike Module
	PyObject * aerospike = Py_InitModule3("aerospike", Aerospike_Methods,
			"Aerospike Python Client");

	py_global_hosts = PyDict_New();
	declare_policy_constants(aerospike);

	PyModule_AddStringConstant(aerospike, "__version__", version);

	PyObject * exception = AerospikeException_New();
	Py_INCREF(exception);
	PyModule_AddObject(aerospike, "exception", exception);

	PyTypeObject * client = AerospikeClient_Ready();
	Py_INCREF(client);
	PyModule_AddObject(aerospike, "Client", (PyObject *) client);

	PyTypeObject * key = AerospikeKey_Ready();
	Py_INCREF(key);
	PyModule_AddObject(aerospike, "Key", (PyObject *) key);

	PyTypeObject * query = AerospikeQuery_Ready();
	Py_INCREF(query);
	PyModule_AddObject(aerospike, "Query", (PyObject *) query);

	declare_policy_constants(aerospike);
	declare_log_constants(aerospike);

	PyTypeObject * scan = AerospikeScan_Ready();
	Py_INCREF(scan);
	PyModule_AddObject(aerospike, "Scan", (PyObject *) scan);

	for (i = 0; i <= OPERATOR_CONSTANTS_ARR_SIZE; i++) {
		PyModule_AddIntConstant(aerospike,
				operator_constants[i].constant_str,
				operator_constants[i].constantno);
	}

	/*
	 * Add constants to module.
	 */
	declare_policy_constants(aerospike);

	PyObject * predicates = AerospikePredicates_New();
	Py_INCREF(predicates);
	PyModule_AddObject(aerospike, "predicates", predicates);


	PyTypeObject * lstack = AerospikeLStack_Ready();
	Py_INCREF(lstack);
	PyModule_AddObject(aerospike, "lstack", (PyObject *) lstack);

	PyTypeObject * lset = AerospikeLSet_Ready();
	Py_INCREF(lset);
	PyModule_AddObject(aerospike, "lset", (PyObject *) lset);

	PyTypeObject * llist = AerospikeLList_Ready();
	Py_INCREF(llist);
	PyModule_AddObject(aerospike, "llist", (PyObject *) llist);

	PyTypeObject * lmap = AerospikeLMap_Ready();
	Py_INCREF(lmap);
	PyModule_AddObject(aerospike, "lmap", (PyObject *) lmap);

	PyTypeObject * geospatial = AerospikeGeospatial_Ready();
	Py_INCREF(geospatial);
	PyModule_AddObject(aerospike, "GeoJSON", (PyObject *) geospatial);

	PyObject * null_object = AerospikeNullObject_New();
	Py_INCREF(null_object);
	PyModule_AddObject(aerospike, "null", (PyObject *) null_object);
}