Large bunch of fixes