big bunch of fixes