code cleanup: types in lib, comments