Finished refactor Fixes #1