Implementation of issue #8

Hi Sean,

Can you please review and recommend any changes you would like? I've tried to follow your coding style as much as possible.

Brian