Add initial code base
Add missing license headers
Replace direction index with enum (slower!)