added logging to stdout, and exit hook to remove locks