Added ApiApplication class, small refactoring