Finish and fix up code