Fixed bad inheritance and several small fixes