Finished code and theory