Some refactorings, slight changes & functionality and fixes