Updated to be better and more flexible.
Closes #96.