refactor and support healthchecks