Rest of fixes from CodeReview #306