Little preperation for future ssh support
Some bigger code reorganisations