V2

Complete rewrite