add startup/shutdown functions. add logging to stderr/stdout