Small restructuring
small fixes