Sobe bug fixes and refactoring