some more minor refactoring, need to extarct Api part