added locks to all printing functions.