Some refactorings, tiny bugfixes and usability improvement