refs #7: refactor and code cleanup