Refactored server class, API bug fixes