Clean package and fix some bugs