Major revision. Configurable options rather than hard coded.