Initial commit, needs lots of refactoring. This is just a quick prototype.