Changed the module interface and added init and close functions.