Http exceptions & some refactoring