Added test cases, fixed bugs, cleaned up code and formatting, and added a new configurable option.