Rewrite
Added Plan. Added more tests.