Updated response parsing, also some code refactoring