Separated lib functions from programme.