reorganize and many fixes