adds debug mode, code organzation