Cleaned up implementation of printf().