alot of fixes and reordering