Cleaned up ps usage, removed awk dependency, added wait for daemon exit.