some further fixes and library implementation