Finilized the first version, but is still buggy