Many many fixes and improvements