Finish basic implementation. Everything thing should be there except binning and some other parameters. Untested so it probably doesn't work.