Fixed bugs + optimised SwitchOutputStream