First completed version submitted. Still need some tests