packaged and several bug fixed