Initial commit of basically functional, but buggy implementation.