clean up logic and variable names; closes #1213