mostly rewritten, implemented keyboard splitting, added license