Refactoring / cleanup
Minor refactoring, small upgrades.