fixed errors, refactored api objects etc