Slightly refactored. Close #10.