Rewrite for 1.5

Needs loads more work.
Complete rewrite