fix some bugs and make it a module