Code cleanup, variable naming, HTTP fail handling

Just bringing this branch up to date with patch-1