big update on structure and small fixes almost everywhere