Complete rewrite and added goodies