Initial commit of working, but buggy and ugly, system