worked a bit on the type system. Seems to moslty work, but needs cleanup!