refactor: code cleanup

Closes #1061