Fix some bugs, fix packaging