API and BB frontend code refactoring for better fault tolerance