Wrapped some more things in "using"s, plus some minor code cleanup