Various changes. UNTESTED. Potentially broken