A bunch of fixes inspired by local C guru