lib: remove dependencies to ugtrain code

The library part is intended to be independent from other code. So
fix that by shifting some small parts. Functionality remains the
same.