Cleaned up service code, ready to PR