http api improvements
even more refactoring