Substantial refactor