Fix logging and pid bugs