Reduce code duplication, cleanup variable names