correctly count bytes in the user level library and other minor fixes