Improvements based on Vinnie's code review.