Refactor and enhance.
Closes #2
Closes #3