Feature/duplicate code cleanup

Closes #5 and #1