Extract service state from Service class.
Resolve some TODOs and fix a bug with rendering pid_file template.