Upd: Properly handle http errors

Also some cleanup of some old code and comments