Refactorisation and comment improvements in misc library.