Some fun with higher kinds
Some minor refactoring