factor hashbase code to library