Fixed type errors. Added further draft implementation.